﻿<%@ Page Title="Edit Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="PageEdit.aspx.cs" Inherits="Altairis.Sewen.WebApp.Sewen.PageEdit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainCPH" runat="server">
    <asp:FormView ID="PageFormView" runat="server" DataSourceID="PageObjectDataSource" RenderOuterTable="false" DefaultMode="Edit" OnItemCommand="PageFormView_ItemCommand" OnItemUpdated="PageFormView_ItemUpdated">
        <EmptyDataTemplate>
            <h1 class="title">Page Not Found</h1>
            <div class="body">
                <p>Specified page was not found.</p>
            </div>
        </EmptyDataTemplate>
        <EditItemTemplate>
            <h1 class="title">
                <asp:Literal runat="server" Text="Edit Page" />
                <asp:Literal ID="LiteralTitle" runat="server" Text='<%# Bind("Title") %>' />
            </h1>
            <div class="head">
                <asp:Literal runat="server" Text='<%# Eval("Version", "Version: {0:d} {0:T}") %>' />
                <asp:Literal runat="server" Text='<%# Eval("UserName", "| User: {0}") %>' />
                <asp:Literal runat="server" Text='<%# Eval("IpAddress", "| IP: {0}") %>' />
            </div>
            <div class="body">
                <asp:TextBox ID="BodyTextBoxHtml" runat="server" Text='<%# Bind("Body") %>' TextMode="MultiLine" Height="400px" />
                <p>
                    <asp:Label runat="server" Text="Comment:" AssociatedControlID="CommentTextBox" />
                    <br />
                    <asp:TextBox ID="CommentTextBox" runat="server" Text='<%# Bind("Comment") %>' />
                </p>
            </div>
            <div class="buttons">
                <asp:RequiredFieldValidator runat="server" ControlToValidate="BodyTextBoxHtml" ErrorMessage="Body is missing" Display="None" />
                <asp:ValidationSummary runat="server" />
                <asp:Button runat="server" CausesValidation="True" CommandName="Update" Text="Update" />
                <asp:Button runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
            </div>
        </EditItemTemplate>
    </asp:FormView>
    <asp:ObjectDataSource ID="PageObjectDataSource" runat="server" TypeName="Altairis.Sewen.PageStoreManager" DataObjectTypeName="Altairis.Sewen.SewenPage" SelectMethod="LoadPage" UpdateMethod="SavePage">
        <SelectParameters>
            <asp:RouteParameter Name="name" RouteKey="slug" Type="String" DefaultValue="home-page" />
        </SelectParameters>
    </asp:ObjectDataSource>
</asp:Content>
